/*
 * 百度在线网络技术（北京）有限公司拥有本软件版权2021并保留所有权利。
 * Copyright 2021, Baidu.com,Inc 2:Baidu Online Network Technology (Beijing) Co.,Ltd,
 * All rights reserved.
 */

package com.azdebugit.test.collection.hashmap;

public class Country {
    String name;
    long population;

    public Country(String name, long population) {
        super();
        this.name = name;
        this.population = population;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public long getPopulation() {
        return population;
    }

    public void setPopulation(long population) {
        this.population = population;
    }

    // If length of name in country object is even then return 31(any random
// number) and if odd then return 95(any random number).
// This is not a good practice to generate hashcode as below method but I am
// doing so to give better and easy understanding of hashmap.
//如果country对象中的名称长度为偶数，则返回31（任意随机值）
//如果是奇数，则返回95（任意随机数）。
//这不是一个好的做法，以生成哈希代码如下方法，但我是
//这样做是为了更好地理解hashmap。
//    @Override
//    public int hashCode() {
//        if (this.name.length() % 2 == 0)
//            return 31;
//        else
//            return 95;
//    }

//    @Override
//    public boolean equals(Object obj) {
//        Country other = (Country) obj;
//        if (name.equalsIgnoreCase((other.name)))
//            return true;
//        return false;
//    }

}


